How would I get an rgb value from color strings like "red" and "green" programmatically? I wanted to make the opacity of things on an html canvas 25%, and I found out you can set the alpha value with ctx.fillStyle = "rgba(...)". However I don't know the rgb values. How can I get it? I tried googling it but the reusults were hex to rgb and rgb to hex.
My current code
let ctx = canvas.getContext("2d");
ctx.fillStyle = this.color; //"red" or "green"
if (condition) ctx.fillStyle = `rgba()` //how to get the values?